package com.wsc.wisdomchina.adapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.wsc.wisdomchina.R;
import com.wsc.wisdomchina.Tools.Tools;
import com.wsc.wisdomchina.javaBean.LifeServerBean;

import java.util.List;

/**
 * 街道特色适配器
 * Created by ${wangtao} on 2017/3/1.
 */

public class LifeServeAdapter extends BaseAdapter {
    private Context context;
    private List<LifeServerBean> messageBeen;

    public LifeServeAdapter(Context context, List<LifeServerBean> messageBeen) {
        this.context = context;
        this.messageBeen = messageBeen;
    }

    @Override
    public int getCount() {
        return messageBeen.size();
    }

    @Override
    public Object getItem(int position) {
        return messageBeen.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
       ViewHolder holder = null;
        View view = convertView;
        if (view == null) {
            view= LayoutInflater.from(context).inflate(R.layout.item_lifeserver,null);
            holder = new ViewHolder(view);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        Glide.with(context).load(messageBeen.get(position).getGuideImg()).into(holder.iv_src);
        holder.tv_title.setText(messageBeen.get(position).getTitle());
        return view;

    }

    public class ViewHolder {
        private ImageView iv_src;//图片
        private TextView tv_title;//标题

        public ViewHolder(View view) {
            iv_src= (ImageView) view.findViewById(R.id.iv_src);
            tv_title= (TextView) view.findViewById(R.id.tv_title);
        }
    }
}
